/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPnlReport.java
 *
 * Created on 20/04/2011, 18:31:48
 */
package systole.view.tabs.results;

import java.awt.BorderLayout;
import java.util.Observable;
import java.util.Observer;
import org.jfree.chart.ChartPanel;
import systole.domain.analysis.Analysis;
import systole.domain.analysis.results.AnalysisResult;
import systole.domain.analysis.results.averages.AverageByDecade;
import systole.domain.report.Report;
import systole.exceptions.ExceptionDAO;
import systole.persistence.FacadeDB;
import systole.view.messages.ReportTexts;

/**
 *
 * @author jmj
 */
public class JPnlReport extends javax.swing.JPanel implements Observer {

    private ChartPanel chartPanel = null;

    /** Creates new form JPnlReport
     * @param analysis 
     */
    public JPnlReport(Analysis analysis) {
        initComponents();
        this.loadAnalysis(analysis);
        int samples=0;
        try{
           AverageByDecade averageByDecade =FacadeDB.getInstance().getAveragesBroker().getAverageByPatient(analysis.getPatient());
           if (averageByDecade!=null){
            samples = averageByDecade.getSamples();
           }
        }catch(ExceptionDAO aO){
            //
        }
        this.jLblIdexCommentSubtitle.setText("<html>" + ReportTexts.ideal_characteristics + "<br>"
                + ReportTexts.values_to + analysis.getPatient().getDecade() + ReportTexts.decade_and_averages +String.valueOf(samples)+ "</html>");
        this.loadResult(analysis.getAnalysisResult());
        this.loadReport(analysis.getReport());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPnlScroll = new javax.swing.JPanel();
        jPnlMain = new javax.swing.JPanel();
        jPnlHeader = new javax.swing.JPanel();
        jPnlCenterHeader = new javax.swing.JPanel();
        jLblTitle = new javax.swing.JLabel();
        jPnlParams = new javax.swing.JPanel();
        jPnlParamsCenter = new javax.swing.JPanel();
        jPnlPatient = new javax.swing.JPanel();
        jPnlLblPatientName = new javax.swing.JPanel();
        jLblName = new javax.swing.JLabel();
        jPnlPatientName = new javax.swing.JPanel();
        jLblPatientName = new javax.swing.JLabel();
        jPnlMedic = new javax.swing.JPanel();
        jLblMedic = new javax.swing.JLabel();
        jPnlPatientInfo = new javax.swing.JPanel();
        jPnlAge = new javax.swing.JPanel();
        jLblAgeValue = new javax.swing.JLabel();
        jLblAge = new javax.swing.JLabel();
        jPnlWeigth = new javax.swing.JPanel();
        jLblWeigthValue = new javax.swing.JLabel();
        jLblWeigth = new javax.swing.JLabel();
        jPnlPS = new javax.swing.JPanel();
        jLblPSValue = new javax.swing.JLabel();
        jLblPS = new javax.swing.JLabel();
        jPnlPD = new javax.swing.JPanel();
        jLblPDValue = new javax.swing.JLabel();
        jLblPD = new javax.swing.JLabel();
        jPnlSmoke = new javax.swing.JPanel();
        jLblSmokeValue = new javax.swing.JLabel();
        jLblSmoke = new javax.swing.JLabel();
        jPnlIndexTitle = new javax.swing.JPanel();
        jLblIndexTitle = new javax.swing.JLabel();
        jPnlPatientIndex = new javax.swing.JPanel();
        jPnlAOD = new javax.swing.JPanel();
        jLblAODValue = new javax.swing.JLabel();
        JlblAOD = new javax.swing.JLabel();
        jPnlIAR = new javax.swing.JPanel();
        jLblIARValue = new javax.swing.JLabel();
        jLblIAR = new javax.swing.JLabel();
        jPnlAOS = new javax.swing.JPanel();
        jLblAOSValue = new javax.swing.JLabel();
        jLblAOS = new javax.swing.JLabel();
        jPnlMC = new javax.swing.JPanel();
        jLblMCValue = new javax.swing.JLabel();
        jLblMC = new javax.swing.JLabel();
        jPnlFC = new javax.swing.JPanel();
        jLblFCValue = new javax.swing.JLabel();
        jLblFC = new javax.swing.JLabel();
        jPnlPlot = new javax.swing.JPanel();
        jPnlPlotCenter = new javax.swing.JPanel();
        jLblPlotTitle = new javax.swing.JLabel();
        jPnlPlotImage = new javax.swing.JPanel();
        jPnlComments = new javax.swing.JPanel();
        jPnlCommentsCenter = new javax.swing.JPanel();
        jLblCommentsValue = new javax.swing.JLabel();
        jLblComments = new javax.swing.JLabel();
        jPnlIndexComments = new javax.swing.JPanel();
        jPnlIndexCommentsCenter = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jLblIdexCommentSubtitle = new javax.swing.JLabel();
        jLblIndexComments = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLblParamComment = new javax.swing.JLabel();
        jPnlBackGround = new javax.swing.JPanel();
        jPnlBackGroundCenter = new javax.swing.JPanel();
        jLblBackgroundValue = new javax.swing.JLabel();
        jLblBackground = new javax.swing.JLabel();
        jPnlConclusion = new javax.swing.JPanel();
        jPnlConclusionCenter = new javax.swing.JPanel();
        jLblConclusionValue = new javax.swing.JLabel();
        jLblConclusion = new javax.swing.JLabel();

        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(632, 800));
        setLayout(new java.awt.BorderLayout());

        jScrollPane1.setName("jScrollPane1"); // NOI18N
        jScrollPane1.setPreferredSize(new java.awt.Dimension(700, 1000));

        jPnlScroll.setName("jPnlScroll"); // NOI18N

        jPnlMain.setName("jPnlMain"); // NOI18N
        jPnlMain.setPreferredSize(new java.awt.Dimension(710, 1000));
        jPnlMain.setLayout(new javax.swing.BoxLayout(jPnlMain, javax.swing.BoxLayout.PAGE_AXIS));

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JPnlReport.class);
        jPnlHeader.setBackground(resourceMap.getColor("jPnlHeader.background")); // NOI18N
        jPnlHeader.setName("jPnlHeader"); // NOI18N
        jPnlHeader.setPreferredSize(new java.awt.Dimension(630, 120));

        jPnlCenterHeader.setBackground(resourceMap.getColor("jPnlCenterHeader.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder1 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder1.setShadowColor(resourceMap.getColor("jPnlCenterHeader.border.shadowColor")); // NOI18N
        dropShadowBorder1.setShadowSize(4);
        dropShadowBorder1.setShowLeftShadow(true);
        dropShadowBorder1.setShowTopShadow(true);
        jPnlCenterHeader.setBorder(dropShadowBorder1);
        jPnlCenterHeader.setName("jPnlCenterHeader"); // NOI18N
        jPnlCenterHeader.setPreferredSize(new java.awt.Dimension(400, 50));
        jPnlCenterHeader.setRequestFocusEnabled(false);
        jPnlCenterHeader.setLayout(new java.awt.BorderLayout());

        jLblTitle.setBackground(resourceMap.getColor("jPnlLeftHeader.background")); // NOI18N
        jLblTitle.setFont(jLblTitle.getFont().deriveFont(jLblTitle.getFont().getStyle() | java.awt.Font.BOLD, jLblTitle.getFont().getSize()+3));
        jLblTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblTitle.setText(resourceMap.getString("jLblTitle.text")); // NOI18N
        jLblTitle.setAutoscrolls(true);
        jLblTitle.setName("jLblTitle"); // NOI18N
        jPnlCenterHeader.add(jLblTitle, java.awt.BorderLayout.CENTER);

        jPnlHeader.add(jPnlCenterHeader);

        jPnlMain.add(jPnlHeader);

        jPnlParams.setBackground(resourceMap.getColor("jPnlParams.background")); // NOI18N
        jPnlParams.setName("jPnlParams"); // NOI18N
        jPnlParams.setPreferredSize(new java.awt.Dimension(500, 210));

        jPnlParamsCenter.setBackground(resourceMap.getColor("jPnlParamsCenter.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder2 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder2.setShadowColor(resourceMap.getColor("jPnlParamsCenter.border.shadowColor")); // NOI18N
        dropShadowBorder2.setShadowSize(4);
        dropShadowBorder2.setShowLeftShadow(true);
        dropShadowBorder2.setShowTopShadow(true);
        jPnlParamsCenter.setBorder(dropShadowBorder2);
        jPnlParamsCenter.setName("jPnlParamsCenter"); // NOI18N
        jPnlParamsCenter.setPreferredSize(new java.awt.Dimension(550, 170));
        jPnlParamsCenter.setLayout(new javax.swing.BoxLayout(jPnlParamsCenter, javax.swing.BoxLayout.PAGE_AXIS));

        jPnlPatient.setName("jPnlPatient"); // NOI18N
        jPnlPatient.setPreferredSize(new java.awt.Dimension(100, 60));
        jPnlPatient.setRequestFocusEnabled(false);
        jPnlPatient.setLayout(new java.awt.BorderLayout());

        jPnlLblPatientName.setBackground(resourceMap.getColor("jPnlLblPatientName.background")); // NOI18N
        jPnlLblPatientName.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jPnlLblPatientName.setName("jPnlLblPatientName"); // NOI18N
        jPnlLblPatientName.setPreferredSize(new java.awt.Dimension(90, 60));
        jPnlLblPatientName.setLayout(new java.awt.BorderLayout());

        jLblName.setFont(jLblName.getFont().deriveFont(jLblName.getFont().getStyle() | java.awt.Font.BOLD, jLblName.getFont().getSize()+2));
        jLblName.setText(resourceMap.getString("jLblName.text")); // NOI18N
        jLblName.setMaximumSize(new java.awt.Dimension(48, 17));
        jLblName.setMinimumSize(new java.awt.Dimension(48, 17));
        jLblName.setName("jLblName"); // NOI18N
        jLblName.setPreferredSize(new java.awt.Dimension(48, 17));
        jPnlLblPatientName.add(jLblName, java.awt.BorderLayout.CENTER);

        jPnlPatient.add(jPnlLblPatientName, java.awt.BorderLayout.WEST);

        jPnlPatientName.setBackground(resourceMap.getColor("jPnlPatientName.background")); // NOI18N
        jPnlPatientName.setName("jPnlPatientName"); // NOI18N
        jPnlPatientName.setPreferredSize(new java.awt.Dimension(100, 40));
        jPnlPatientName.setLayout(new java.awt.BorderLayout());

        jLblPatientName.setFont(jLblPatientName.getFont().deriveFont(jLblPatientName.getFont().getStyle() | java.awt.Font.BOLD, jLblPatientName.getFont().getSize()+2));
        jLblPatientName.setText(resourceMap.getString("jLblPatientName.text")); // NOI18N
        jLblPatientName.setName("jLblPatientName"); // NOI18N
        jPnlPatientName.add(jLblPatientName, java.awt.BorderLayout.CENTER);

        jPnlPatient.add(jPnlPatientName, java.awt.BorderLayout.CENTER);

        jPnlParamsCenter.add(jPnlPatient);

        jPnlMedic.setBackground(resourceMap.getColor("jPnlMedic.background")); // NOI18N
        jPnlMedic.setName("jPnlMedic"); // NOI18N
        jPnlMedic.setPreferredSize(new java.awt.Dimension(10, 40));
        jPnlMedic.setLayout(new java.awt.BorderLayout());

        jLblMedic.setText(resourceMap.getString("jLblMedic.text")); // NOI18N
        jLblMedic.setName("jLblMedic"); // NOI18N
        jPnlMedic.add(jLblMedic, java.awt.BorderLayout.CENTER);

        jPnlParamsCenter.add(jPnlMedic);

        jPnlPatientInfo.setBackground(resourceMap.getColor("jPnlPatientInfo.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder3 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder3.setShadowColor(resourceMap.getColor("jPnlPatientInfo.border.shadowColor")); // NOI18N
        dropShadowBorder3.setShadowSize(4);
        dropShadowBorder3.setShowBottomShadow(false);
        dropShadowBorder3.setShowRightShadow(false);
        dropShadowBorder3.setShowTopShadow(true);
        jPnlPatientInfo.setBorder(dropShadowBorder3);
        jPnlPatientInfo.setName("jPnlPatientInfo"); // NOI18N
        jPnlPatientInfo.setLayout(new java.awt.GridLayout(1, 0));

        jPnlAge.setBackground(resourceMap.getColor("jPnlAge.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder4 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder4.setShadowColor(resourceMap.getColor("jPnlAge.border.shadowColor")); // NOI18N
        dropShadowBorder4.setShadowSize(4);
        dropShadowBorder4.setShowBottomShadow(false);
        jPnlAge.setBorder(dropShadowBorder4);
        jPnlAge.setName("jPnlAge"); // NOI18N
        jPnlAge.setPreferredSize(new java.awt.Dimension(40, 40));
        jPnlAge.setLayout(new java.awt.BorderLayout());

        jLblAgeValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblAgeValue.setText(resourceMap.getString("jLblAgeValue.text")); // NOI18N
        jLblAgeValue.setName("jLblAgeValue"); // NOI18N
        jPnlAge.add(jLblAgeValue, java.awt.BorderLayout.SOUTH);

        jLblAge.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblAge.setText(resourceMap.getString("jLblAge.text")); // NOI18N
        jLblAge.setName("jLblAge"); // NOI18N
        jPnlAge.add(jLblAge, java.awt.BorderLayout.CENTER);

        jPnlPatientInfo.add(jPnlAge);

        jPnlWeigth.setBackground(resourceMap.getColor("jPnlWeigth.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder5 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder5.setShadowColor(resourceMap.getColor("jPnlWeigth.border.shadowColor")); // NOI18N
        dropShadowBorder5.setShadowSize(4);
        dropShadowBorder5.setShowBottomShadow(false);
        jPnlWeigth.setBorder(dropShadowBorder5);
        jPnlWeigth.setName("jPnlWeigth"); // NOI18N
        jPnlWeigth.setPreferredSize(new java.awt.Dimension(40, 40));
        jPnlWeigth.setLayout(new java.awt.BorderLayout());

        jLblWeigthValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblWeigthValue.setText(resourceMap.getString("jLblWeigthValue.text")); // NOI18N
        jLblWeigthValue.setName("jLblWeigthValue"); // NOI18N
        jPnlWeigth.add(jLblWeigthValue, java.awt.BorderLayout.SOUTH);

        jLblWeigth.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblWeigth.setText(resourceMap.getString("jLblWeigth.text")); // NOI18N
        jLblWeigth.setName("jLblWeigth"); // NOI18N
        jPnlWeigth.add(jLblWeigth, java.awt.BorderLayout.CENTER);

        jPnlPatientInfo.add(jPnlWeigth);

        jPnlPS.setBackground(resourceMap.getColor("jPnlPS.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder6 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder6.setShadowColor(resourceMap.getColor("jPnlPS.border.shadowColor")); // NOI18N
        dropShadowBorder6.setShadowSize(4);
        dropShadowBorder6.setShowBottomShadow(false);
        jPnlPS.setBorder(dropShadowBorder6);
        jPnlPS.setName("jPnlPS"); // NOI18N
        jPnlPS.setPreferredSize(new java.awt.Dimension(40, 40));
        jPnlPS.setLayout(new java.awt.BorderLayout());

        jLblPSValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblPSValue.setText(resourceMap.getString("jLblPSValue.text")); // NOI18N
        jLblPSValue.setName("jLblPSValue"); // NOI18N
        jPnlPS.add(jLblPSValue, java.awt.BorderLayout.SOUTH);

        jLblPS.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblPS.setText(resourceMap.getString("jLblPS.text")); // NOI18N
        jLblPS.setName("jLblPS"); // NOI18N
        jPnlPS.add(jLblPS, java.awt.BorderLayout.CENTER);

        jPnlPatientInfo.add(jPnlPS);

        jPnlPD.setBackground(resourceMap.getColor("jPnlPD.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder7 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder7.setShadowColor(resourceMap.getColor("jPnlPD.border.shadowColor")); // NOI18N
        dropShadowBorder7.setShadowSize(4);
        dropShadowBorder7.setShowBottomShadow(false);
        jPnlPD.setBorder(dropShadowBorder7);
        jPnlPD.setName("jPnlPD"); // NOI18N
        jPnlPD.setPreferredSize(new java.awt.Dimension(40, 40));
        jPnlPD.setLayout(new java.awt.BorderLayout());

        jLblPDValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblPDValue.setText(resourceMap.getString("jLblPDValue.text")); // NOI18N
        jLblPDValue.setName("jLblPDValue"); // NOI18N
        jPnlPD.add(jLblPDValue, java.awt.BorderLayout.SOUTH);

        jLblPD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblPD.setText(resourceMap.getString("jLblPD.text")); // NOI18N
        jLblPD.setName("jLblPD"); // NOI18N
        jPnlPD.add(jLblPD, java.awt.BorderLayout.CENTER);

        jPnlPatientInfo.add(jPnlPD);

        jPnlSmoke.setBackground(resourceMap.getColor("jPnlSmoke.background")); // NOI18N
        jPnlSmoke.setName("jPnlSmoke"); // NOI18N
        jPnlSmoke.setPreferredSize(new java.awt.Dimension(40, 40));
        jPnlSmoke.setLayout(new java.awt.BorderLayout());

        jLblSmokeValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblSmokeValue.setText(resourceMap.getString("jLblSmokeValue.text")); // NOI18N
        jLblSmokeValue.setName("jLblSmokeValue"); // NOI18N
        jPnlSmoke.add(jLblSmokeValue, java.awt.BorderLayout.SOUTH);

        jLblSmoke.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblSmoke.setText(resourceMap.getString("jLblSmoke.text")); // NOI18N
        jLblSmoke.setName("jLblSmoke"); // NOI18N
        jPnlSmoke.add(jLblSmoke, java.awt.BorderLayout.CENTER);

        jPnlPatientInfo.add(jPnlSmoke);

        jPnlParamsCenter.add(jPnlPatientInfo);

        jPnlIndexTitle.setBackground(resourceMap.getColor("jPnlIndexTitle.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder8 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder8.setShadowColor(resourceMap.getColor("jPnlIndexTitle.border.shadowColor")); // NOI18N
        dropShadowBorder8.setShadowSize(4);
        dropShadowBorder8.setShowBottomShadow(false);
        dropShadowBorder8.setShowRightShadow(false);
        dropShadowBorder8.setShowTopShadow(true);
        jPnlIndexTitle.setBorder(dropShadowBorder8);
        jPnlIndexTitle.setName("jPnlIndexTitle"); // NOI18N
        jPnlIndexTitle.setLayout(new java.awt.BorderLayout());

        jLblIndexTitle.setFont(jLblIndexTitle.getFont().deriveFont(jLblIndexTitle.getFont().getStyle() | java.awt.Font.BOLD, jLblIndexTitle.getFont().getSize()+2));
        jLblIndexTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblIndexTitle.setText(resourceMap.getString("jLblIndexTitle.text")); // NOI18N
        jLblIndexTitle.setName("jLblIndexTitle"); // NOI18N
        jPnlIndexTitle.add(jLblIndexTitle, java.awt.BorderLayout.CENTER);

        jPnlParamsCenter.add(jPnlIndexTitle);

        jPnlPatientIndex.setBackground(resourceMap.getColor("jPnlPatientIndex.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder9 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder9.setShadowColor(resourceMap.getColor("jPnlPatientIndex.border.shadowColor")); // NOI18N
        dropShadowBorder9.setShadowSize(4);
        dropShadowBorder9.setShowBottomShadow(false);
        dropShadowBorder9.setShowRightShadow(false);
        dropShadowBorder9.setShowTopShadow(true);
        jPnlPatientIndex.setBorder(dropShadowBorder9);
        jPnlPatientIndex.setName("jPnlPatientIndex"); // NOI18N
        jPnlPatientIndex.setPreferredSize(new java.awt.Dimension(200, 200));
        jPnlPatientIndex.setLayout(new java.awt.GridLayout(1, 0));

        jPnlAOD.setBackground(resourceMap.getColor("jPnlAOD.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder10 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder10.setShadowColor(resourceMap.getColor("jPnlAOD.border.shadowColor")); // NOI18N
        dropShadowBorder10.setShadowSize(4);
        dropShadowBorder10.setShowBottomShadow(false);
        jPnlAOD.setBorder(dropShadowBorder10);
        jPnlAOD.setName("jPnlAOD"); // NOI18N
        jPnlAOD.setPreferredSize(new java.awt.Dimension(40, 40));
        jPnlAOD.setLayout(new java.awt.BorderLayout());

        jLblAODValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblAODValue.setText(resourceMap.getString("jLblAODValue.text")); // NOI18N
        jLblAODValue.setName("jLblAODValue"); // NOI18N
        jPnlAOD.add(jLblAODValue, java.awt.BorderLayout.SOUTH);

        JlblAOD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        JlblAOD.setText(resourceMap.getString("JlblAOD.text")); // NOI18N
        JlblAOD.setName("JlblAOD"); // NOI18N
        jPnlAOD.add(JlblAOD, java.awt.BorderLayout.CENTER);

        jPnlPatientIndex.add(jPnlAOD);

        jPnlIAR.setBackground(resourceMap.getColor("jPnlIAR.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder11 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder11.setShadowColor(resourceMap.getColor("jPnlIAR.border.shadowColor")); // NOI18N
        dropShadowBorder11.setShadowSize(4);
        dropShadowBorder11.setShowBottomShadow(false);
        jPnlIAR.setBorder(dropShadowBorder11);
        jPnlIAR.setName("jPnlIAR"); // NOI18N
        jPnlIAR.setLayout(new java.awt.BorderLayout());

        jLblIARValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblIARValue.setText(resourceMap.getString("jLblIARValue.text")); // NOI18N
        jLblIARValue.setName("jLblIARValue"); // NOI18N
        jPnlIAR.add(jLblIARValue, java.awt.BorderLayout.SOUTH);

        jLblIAR.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblIAR.setText(resourceMap.getString("jLblIAR.text")); // NOI18N
        jLblIAR.setName("jLblIAR"); // NOI18N
        jPnlIAR.add(jLblIAR, java.awt.BorderLayout.CENTER);

        jPnlPatientIndex.add(jPnlIAR);

        jPnlAOS.setBackground(resourceMap.getColor("jPnlAOS.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder12 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder12.setShadowColor(resourceMap.getColor("jPnlAOS.border.shadowColor")); // NOI18N
        dropShadowBorder12.setShadowSize(4);
        dropShadowBorder12.setShowBottomShadow(false);
        jPnlAOS.setBorder(dropShadowBorder12);
        jPnlAOS.setName("jPnlAOS"); // NOI18N
        jPnlAOS.setLayout(new java.awt.BorderLayout());

        jLblAOSValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblAOSValue.setText(resourceMap.getString("jLblAOSValue.text")); // NOI18N
        jLblAOSValue.setName("jLblAOSValue"); // NOI18N
        jPnlAOS.add(jLblAOSValue, java.awt.BorderLayout.SOUTH);

        jLblAOS.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblAOS.setText(resourceMap.getString("jLblAOS.text")); // NOI18N
        jLblAOS.setName("jLblAOS"); // NOI18N
        jPnlAOS.add(jLblAOS, java.awt.BorderLayout.CENTER);

        jPnlPatientIndex.add(jPnlAOS);

        jPnlMC.setBackground(resourceMap.getColor("jPnlMC.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder13 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder13.setShadowColor(resourceMap.getColor("jPnlMC.border.shadowColor")); // NOI18N
        dropShadowBorder13.setShadowSize(4);
        dropShadowBorder13.setShowBottomShadow(false);
        jPnlMC.setBorder(dropShadowBorder13);
        jPnlMC.setName("jPnlMC"); // NOI18N
        jPnlMC.setLayout(new java.awt.BorderLayout());

        jLblMCValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblMCValue.setText(resourceMap.getString("jLblMCValue.text")); // NOI18N
        jLblMCValue.setName("jLblMCValue"); // NOI18N
        jPnlMC.add(jLblMCValue, java.awt.BorderLayout.SOUTH);

        jLblMC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblMC.setText(resourceMap.getString("jLblMC.text")); // NOI18N
        jLblMC.setName("jLblMC"); // NOI18N
        jPnlMC.add(jLblMC, java.awt.BorderLayout.CENTER);

        jPnlPatientIndex.add(jPnlMC);

        jPnlFC.setBackground(resourceMap.getColor("jPnlFC.background")); // NOI18N
        jPnlFC.setName("jPnlFC"); // NOI18N
        jPnlFC.setLayout(new java.awt.BorderLayout());

        jLblFCValue.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblFCValue.setText(resourceMap.getString("jLblFCValue.text")); // NOI18N
        jLblFCValue.setName("jLblFCValue"); // NOI18N
        jPnlFC.add(jLblFCValue, java.awt.BorderLayout.SOUTH);

        jLblFC.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblFC.setText(resourceMap.getString("jLblFC.text")); // NOI18N
        jLblFC.setName("jLblFC"); // NOI18N
        jPnlFC.add(jLblFC, java.awt.BorderLayout.CENTER);

        jPnlPatientIndex.add(jPnlFC);

        jPnlParamsCenter.add(jPnlPatientIndex);

        jPnlParams.add(jPnlParamsCenter);

        jPnlMain.add(jPnlParams);

        jPnlPlot.setBackground(resourceMap.getColor("jPnlPlot.background")); // NOI18N
        jPnlPlot.setName("jPnlPlot"); // NOI18N
        jPnlPlot.setPreferredSize(new java.awt.Dimension(500, 270));

        jPnlPlotCenter.setBackground(resourceMap.getColor("jPnlPlotCenter.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder14 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder14.setShadowColor(resourceMap.getColor("jPnlPlotCenter.border.shadowColor")); // NOI18N
        dropShadowBorder14.setShadowSize(4);
        dropShadowBorder14.setShowLeftShadow(true);
        dropShadowBorder14.setShowTopShadow(true);
        jPnlPlotCenter.setBorder(dropShadowBorder14);
        jPnlPlotCenter.setName("jPnlPlotCenter"); // NOI18N
        jPnlPlotCenter.setPreferredSize(new java.awt.Dimension(350, 140));
        jPnlPlotCenter.setLayout(new java.awt.BorderLayout());

        jLblPlotTitle.setFont(jLblPlotTitle.getFont().deriveFont(jLblPlotTitle.getFont().getStyle() | java.awt.Font.BOLD, jLblPlotTitle.getFont().getSize()+2));
        jLblPlotTitle.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLblPlotTitle.setText(resourceMap.getString("jLblPlotTitle.text")); // NOI18N
        jLblPlotTitle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLblPlotTitle.setName("jLblPlotTitle"); // NOI18N
        jPnlPlotCenter.add(jLblPlotTitle, java.awt.BorderLayout.WEST);

        jPnlPlotImage.setBackground(resourceMap.getColor("jPnlPlotImage.background")); // NOI18N
        org.jdesktop.swingx.border.DropShadowBorder dropShadowBorder15 = new org.jdesktop.swingx.border.DropShadowBorder();
        dropShadowBorder15.setShadowColor(resourceMap.getColor("jPnlPlotImage.border.shadowColor")); // NOI18N
        dropShadowBorder15.setShadowSize(4);
        dropShadowBorder15.setShowBottomShadow(false);
        dropShadowBorder15.setShowLeftShadow(true);
        dropShadowBorder15.setShowRightShadow(false);
        jPnlPlotImage.setBorder(dropShadowBorder15);
        jPnlPlotImage.setName("jPnlPlotImage"); // NOI18N
        jPnlPlotImage.setLayout(new java.awt.BorderLayout());
        jPnlPlotCenter.add(jPnlPlotImage, java.awt.BorderLayout.CENTER);

        jPnlPlot.add(jPnlPlotCenter);

        jPnlMain.add(jPnlPlot);

        jPnlComments.setBackground(resourceMap.getColor("jPnlComments.background")); // NOI18N
        jPnlComments.setName("jPnlComments"); // NOI18N
        jPnlComments.setPreferredSize(new java.awt.Dimension(500, 100));

        jPnlCommentsCenter.setBackground(resourceMap.getColor("jPnlCommentsCenter.background")); // NOI18N
        jPnlCommentsCenter.setName("jPnlCommentsCenter"); // NOI18N
        jPnlCommentsCenter.setPreferredSize(new java.awt.Dimension(600, 65));
        jPnlCommentsCenter.setLayout(new java.awt.BorderLayout());

        jLblCommentsValue.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLblCommentsValue.setText(resourceMap.getString("jLblCommentsValue.text")); // NOI18N
        jLblCommentsValue.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLblCommentsValue.setName("jLblCommentsValue"); // NOI18N
        jPnlCommentsCenter.add(jLblCommentsValue, java.awt.BorderLayout.CENTER);

        jLblComments.setFont(jLblComments.getFont().deriveFont(jLblComments.getFont().getStyle() | java.awt.Font.BOLD, jLblComments.getFont().getSize()+1));
        jLblComments.setText(resourceMap.getString("jLblComments.text")); // NOI18N
        jLblComments.setName("jLblComments"); // NOI18N
        jPnlCommentsCenter.add(jLblComments, java.awt.BorderLayout.NORTH);

        jPnlComments.add(jPnlCommentsCenter);

        jPnlMain.add(jPnlComments);

        jPnlIndexComments.setBackground(resourceMap.getColor("jPnlIndexComments.background")); // NOI18N
        jPnlIndexComments.setName("jPnlIndexComments"); // NOI18N
        jPnlIndexComments.setPreferredSize(new java.awt.Dimension(550, 170));

        jPnlIndexCommentsCenter.setBackground(resourceMap.getColor("jPnlIndexCommentsCenter.background")); // NOI18N
        jPnlIndexCommentsCenter.setName("jPnlIndexCommentsCenter"); // NOI18N
        jPnlIndexCommentsCenter.setPreferredSize(new java.awt.Dimension(600, 140));
        jPnlIndexCommentsCenter.setLayout(new java.awt.BorderLayout());

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(370, 45));
        jPanel1.setLayout(new java.awt.BorderLayout());

        jLblIdexCommentSubtitle.setFont(jLblIdexCommentSubtitle.getFont().deriveFont((jLblIdexCommentSubtitle.getFont().getStyle() | java.awt.Font.ITALIC), jLblIdexCommentSubtitle.getFont().getSize()-1));
        jLblIdexCommentSubtitle.setText(resourceMap.getString("jLblIdexCommentSubtitle.text")); // NOI18N
        jLblIdexCommentSubtitle.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLblIdexCommentSubtitle.setName("jLblIdexCommentSubtitle"); // NOI18N
        jPanel1.add(jLblIdexCommentSubtitle, java.awt.BorderLayout.CENTER);

        jLblIndexComments.setFont(jLblIndexComments.getFont().deriveFont(jLblIndexComments.getFont().getStyle() | java.awt.Font.BOLD, jLblIndexComments.getFont().getSize()+1));
        jLblIndexComments.setText(resourceMap.getString("jLblIndexComments.text")); // NOI18N
        jLblIndexComments.setName("jLblIndexComments"); // NOI18N
        jPanel1.add(jLblIndexComments, java.awt.BorderLayout.PAGE_START);

        jPnlIndexCommentsCenter.add(jPanel1, java.awt.BorderLayout.NORTH);

        jPanel2.setBackground(resourceMap.getColor("jPanel2.background")); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setLayout(new java.awt.BorderLayout());

        jLblParamComment.setText(resourceMap.getString("jLblParamComment.text")); // NOI18N
        jLblParamComment.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLblParamComment.setName("jLblParamComment"); // NOI18N
        jPanel2.add(jLblParamComment, java.awt.BorderLayout.CENTER);

        jPnlIndexCommentsCenter.add(jPanel2, java.awt.BorderLayout.CENTER);

        jPnlIndexComments.add(jPnlIndexCommentsCenter);

        jPnlMain.add(jPnlIndexComments);

        jPnlBackGround.setBackground(resourceMap.getColor("jPnlBackGround.background")); // NOI18N
        jPnlBackGround.setName("jPnlBackGround"); // NOI18N
        jPnlBackGround.setPreferredSize(new java.awt.Dimension(500, 160));

        jPnlBackGroundCenter.setBackground(resourceMap.getColor("jPnlBackGroundCenter.background")); // NOI18N
        jPnlBackGroundCenter.setName("jPnlBackGroundCenter"); // NOI18N
        jPnlBackGroundCenter.setPreferredSize(new java.awt.Dimension(600, 140));
        jPnlBackGroundCenter.setLayout(new java.awt.BorderLayout());

        jLblBackgroundValue.setText(resourceMap.getString("jLblBackgroundValue.text")); // NOI18N
        jLblBackgroundValue.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLblBackgroundValue.setName("jLblBackgroundValue"); // NOI18N
        jPnlBackGroundCenter.add(jLblBackgroundValue, java.awt.BorderLayout.CENTER);

        jLblBackground.setFont(jLblBackground.getFont().deriveFont(jLblBackground.getFont().getStyle() | java.awt.Font.BOLD, jLblBackground.getFont().getSize()+1));
        jLblBackground.setText(resourceMap.getString("jLblBackground.text")); // NOI18N
        jLblBackground.setName("jLblBackground"); // NOI18N
        jPnlBackGroundCenter.add(jLblBackground, java.awt.BorderLayout.NORTH);

        jPnlBackGround.add(jPnlBackGroundCenter);

        jPnlMain.add(jPnlBackGround);

        jPnlConclusion.setBackground(resourceMap.getColor("jPnlConclusion.background")); // NOI18N
        jPnlConclusion.setName("jPnlConclusion"); // NOI18N
        jPnlConclusion.setPreferredSize(new java.awt.Dimension(500, 170));

        jPnlConclusionCenter.setBackground(resourceMap.getColor("jPnlConclusionCenter.background")); // NOI18N
        jPnlConclusionCenter.setName("jPnlConclusionCenter"); // NOI18N
        jPnlConclusionCenter.setPreferredSize(new java.awt.Dimension(600, 150));
        jPnlConclusionCenter.setLayout(new java.awt.BorderLayout());

        jLblConclusionValue.setText(resourceMap.getString("jLblConclusionValue.text")); // NOI18N
        jLblConclusionValue.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jLblConclusionValue.setName("jLblConclusionValue"); // NOI18N
        jPnlConclusionCenter.add(jLblConclusionValue, java.awt.BorderLayout.CENTER);

        jLblConclusion.setFont(jLblConclusion.getFont().deriveFont(jLblConclusion.getFont().getStyle() | java.awt.Font.BOLD, jLblConclusion.getFont().getSize()+1));
        jLblConclusion.setText(resourceMap.getString("jLblConclusion.text")); // NOI18N
        jLblConclusion.setName("jLblConclusion"); // NOI18N
        jPnlConclusionCenter.add(jLblConclusion, java.awt.BorderLayout.NORTH);

        jPnlConclusion.add(jPnlConclusionCenter);

        jPnlMain.add(jPnlConclusion);

        jPnlScroll.add(jPnlMain);

        jScrollPane1.setViewportView(jPnlScroll);

        add(jScrollPane1, java.awt.BorderLayout.CENTER);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel JlblAOD;
    private javax.swing.JLabel jLblAODValue;
    private javax.swing.JLabel jLblAOS;
    private javax.swing.JLabel jLblAOSValue;
    private javax.swing.JLabel jLblAge;
    private javax.swing.JLabel jLblAgeValue;
    private javax.swing.JLabel jLblBackground;
    private javax.swing.JLabel jLblBackgroundValue;
    private javax.swing.JLabel jLblComments;
    private javax.swing.JLabel jLblCommentsValue;
    private javax.swing.JLabel jLblConclusion;
    private javax.swing.JLabel jLblConclusionValue;
    private javax.swing.JLabel jLblFC;
    private javax.swing.JLabel jLblFCValue;
    private javax.swing.JLabel jLblIAR;
    private javax.swing.JLabel jLblIARValue;
    private javax.swing.JLabel jLblIdexCommentSubtitle;
    private javax.swing.JLabel jLblIndexComments;
    private javax.swing.JLabel jLblIndexTitle;
    private javax.swing.JLabel jLblMC;
    private javax.swing.JLabel jLblMCValue;
    private javax.swing.JLabel jLblMedic;
    private javax.swing.JLabel jLblName;
    private javax.swing.JLabel jLblPD;
    private javax.swing.JLabel jLblPDValue;
    private javax.swing.JLabel jLblPS;
    private javax.swing.JLabel jLblPSValue;
    private javax.swing.JLabel jLblParamComment;
    private javax.swing.JLabel jLblPatientName;
    private javax.swing.JLabel jLblPlotTitle;
    private javax.swing.JLabel jLblSmoke;
    private javax.swing.JLabel jLblSmokeValue;
    private javax.swing.JLabel jLblTitle;
    private javax.swing.JLabel jLblWeigth;
    private javax.swing.JLabel jLblWeigthValue;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPnlAOD;
    private javax.swing.JPanel jPnlAOS;
    private javax.swing.JPanel jPnlAge;
    private javax.swing.JPanel jPnlBackGround;
    private javax.swing.JPanel jPnlBackGroundCenter;
    private javax.swing.JPanel jPnlCenterHeader;
    private javax.swing.JPanel jPnlComments;
    private javax.swing.JPanel jPnlCommentsCenter;
    private javax.swing.JPanel jPnlConclusion;
    private javax.swing.JPanel jPnlConclusionCenter;
    private javax.swing.JPanel jPnlFC;
    private javax.swing.JPanel jPnlHeader;
    private javax.swing.JPanel jPnlIAR;
    private javax.swing.JPanel jPnlIndexComments;
    private javax.swing.JPanel jPnlIndexCommentsCenter;
    private javax.swing.JPanel jPnlIndexTitle;
    private javax.swing.JPanel jPnlLblPatientName;
    private javax.swing.JPanel jPnlMC;
    private javax.swing.JPanel jPnlMain;
    private javax.swing.JPanel jPnlMedic;
    private javax.swing.JPanel jPnlPD;
    private javax.swing.JPanel jPnlPS;
    private javax.swing.JPanel jPnlParams;
    private javax.swing.JPanel jPnlParamsCenter;
    private javax.swing.JPanel jPnlPatient;
    private javax.swing.JPanel jPnlPatientIndex;
    private javax.swing.JPanel jPnlPatientInfo;
    private javax.swing.JPanel jPnlPatientName;
    private javax.swing.JPanel jPnlPlot;
    private javax.swing.JPanel jPnlPlotCenter;
    private javax.swing.JPanel jPnlPlotImage;
    private javax.swing.JPanel jPnlScroll;
    private javax.swing.JPanel jPnlSmoke;
    private javax.swing.JPanel jPnlWeigth;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables

    public void update(Observable o, Object arg) {
        Report report = (Report) arg;
        this.loadReport(report);
    }

    public final void loadReport(Report report) {

        if (report != null) {
            this.jLblCommentsValue.setText(report.getCommentsAsHtml());
            this.jLblConclusionValue.setText(report.getConclusionAsHtml());
            this.jLblParamComment.setText(report.getAllParamsCommentsAsHtml());
            this.jLblBackgroundValue.setText(report.getAllBackgroundAsHtml());
        }
        this.revalidate();
    }

    public final void loadResult(AnalysisResult analysisResult) {
        if (analysisResult != null) {
            this.jLblAODValue.setText(analysisResult.getAod().getValueAsString());
            this.jLblAOSValue.setText(analysisResult.getAos().getValueAsString());
            this.jLblFCValue.setText(analysisResult.getHeartRateAsString());
            this.jLblIARValue.setText(analysisResult.getIar().getValueAsString());
        }
        this.revalidate();
    }

    private void loadAnalysis(Analysis analysis) {

        this.jLblPatientName.setText(analysis.getPatient().getFullName());

        if (analysis.getMedic() != null) {
            this.jLblMedic.setText(ReportTexts.request_by + " " + analysis.getMedic().getFullName());
        } else {
            this.jLblMedic.setVisible(false);
        }

        this.jLblWeigthValue.setText(analysis.getClinicalInformation().getWeightAsString(false));
        this.jLblAgeValue.setText(analysis.getClinicalInformation().getYearsAsString());
        this.jLblPSValue.setText(analysis.getClinicalInformation().getSystolicPressureAsString(false));
        this.jLblPDValue.setText(analysis.getClinicalInformation().getDiastolicPressureAsString(false));
        this.jLblSmokeValue.setText((analysis.getPatient().getHabitPatient() == null) ? "" : (analysis.getPatient().getHabitPatient().isSmoker()) ? "Si" : "No");
        this.jLblMCValue.setText(analysis.getClinicalInformation().getIMCasString());
    }

    public void loadNewChart(ChartPanel chartPanel) {
        this.chartPanel = chartPanel;
        this.jPnlPlotImage.add(this.chartPanel, BorderLayout.CENTER);
        this.jPnlPlotImage.revalidate();
    }
}
